<?php

    /**
     * Writes the url corresponding to the given action
     *
     * @param       Dwoo         $dwoo
     * @param       string       $selector : selector action
     * @param       array        $params : parameters for the url
     * @param       boolean      $escape : if true, then escape the string for html
     * @return      string
     */
    function Dwoo_Plugin_url(Dwoo $dwoo, $selector, $params = array(), $escape = true, $end = null, $protocol = 'http')
    {
        $registry = Zend_Registry::getInstance();

        if ($end === null) {
            $end = $registry['end'];
        }

        switch($end) {
            case 'front':
                return DbPage::getUrl($selector, $params);
            case 'admin':
            default:
                return Core_Url::get($selector, $params, ($escape ? Core_Url::XMLSTRING : Core_Url::STRING));
        }
    }
